import java.sql.*;

public class select {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        String url = "jdbc:mysql://127.0.0.1:3306/db4?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true";
        //数据库账号
        String user="root";
        //数据库密码
        String password="cnj147759399";
        Connection connection = DriverManager.getConnection(url, user, password);
        Statement statement = connection.createStatement();
        String  sql  = "SELECT * FROM cat";
        ResultSet rs = statement.executeQuery(sql);
        while (rs.next()){
            System.out.println("ID="+rs.getObject("ID"));
            System.out.println("name="+rs.getObject("名字"));
            System.out.println("height="+rs.getObject("体重"));
            System.out.println("birth="+rs.getObject("出生日期"));
        }
        rs.close();
        statement.close();
        connection.close();
    }
}
